package com.link2room.quintesson;

import com.link2room.common.mns.Worker;
import com.link2room.common.mns.listener.MnsListener;
import com.link2room.quintesson.constant.QuintessonMnsConstant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 加载mns消息服务轮询服务
 * Created by LN on 2016/8/25.
 */
@Component  //使用时，打开注释
public class QuintessonMNSPollingStartupRunner implements CommandLineRunner {

    @Resource //需要实现此接口
    private Worker taobaoXhotelRunner;
    @Resource //需要实现此接口
    private Worker taobaoXroomtypeRunner;
    @Resource
    private Worker taobaoXrateplanRunner;
    @Resource
    private Worker taobaoXrateRunner;
    @Resource
    private Worker taobaoXrateIncrementRunner;
    @Resource
    private MnsListener defaultMnsListener;


    private static Logger logger = LoggerFactory.getLogger(QuintessonMNSPollingStartupRunner.class);
    @Override
    public void run(String... strings) throws Exception {
        defaultMnsListener.startPolling(QuintessonMnsConstant.QUEUE_UP_TAOBAO_XHOTEL,taobaoXhotelRunner,5);
        defaultMnsListener.startPolling(QuintessonMnsConstant.QUEUE_UP_TAOBAO_XROOMTYPE,taobaoXroomtypeRunner,5);
        defaultMnsListener.startPolling(QuintessonMnsConstant.QUEUE_UP_TAOBAO_XRATEPLAN,taobaoXrateplanRunner,5);
        defaultMnsListener.startPolling(QuintessonMnsConstant.QUEUE_UP_TAOBAO_XRATE,taobaoXrateRunner,5);
        defaultMnsListener.startPolling(QuintessonMnsConstant.QUEUE_UP_TAOBAO_XRATE_INCREMENT,taobaoXrateIncrementRunner,5);
    }
}
